package sismed.gui.comando;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import sismed.negocio.fachada.Fachada;
import sismed.negocio.modelo.Farmaceutico;
import sismed.negocio.modelo.Paciente;

public class ComandoCarregarPrescreverExame extends ComandoGenerico {

	@Override
	public void executar( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println( "entrei" );
		Fachada fachada = Fachada.getInstance();
		List<Paciente> listaPacientes = fachada.recuperarListaPacientes();
		List<Farmaceutico> listaFarmaceuticos = fachada.recuperarListaFarmaceuticos();
		try {		
			request.setAttribute( "ListaPacientes", listaPacientes );
			request.setAttribute( "ListaFarmaceuticos", listaFarmaceuticos );
			request.getRequestDispatcher( "prescreverExame.jsp" ).forward( request, response );	
		} 
		catch ( Exception e ) {
			response.sendRedirect("erro.jsp?msgerro=Erro ao recuperar mensagens.");	
		}
	}
}
